<?php
require_once('../classes/map/Maze.php');
require_once('../classes/shared/RandomTools.php');
require_once('../classes/text/RandomText.php');
require_once('../classes/text/RandomMiscText.php');

$maze = new RPGMaze(21, 21);
$maze->proba_glitch = isset($_REQUEST['glitch']) ? $_REQUEST['glitch'] : 0;
$maze->getIterativeMaze(1,1);

$cells_js= json_encode($maze->cells);

mt_srand();

?><html>
<body>
	<h1><?php echo RPGRandomMiscText::getDungeonName(); ?></h1>
	<canvas id="myCanvas" width="2000" height="2000"></canvas>
	<script>
		// Le niveau de ZOOM
		var pixel_size = 12;

		var shapeArray = <?php echo $cells_js; ?>;

		function drawArray(array) {
			// Le plan
			for (var y=0, count_y = array.length; y < count_y; y++) {
				for (var x=0, count_x = array[y].length; x < count_x; x++) {
					if (array[y][x] == 0) {
						context.fillStyle = '#000';
					} else if (array[y][x] == 2) {
						context.fillStyle = '#F00';
					} else {
						context.fillStyle = '#FFF';
					}
					context.fillRect(x*pixel_size, y*pixel_size, pixel_size, pixel_size);
				}
			}

		}


		var canvas = document.getElementById('myCanvas');
		var context = canvas.getContext('2d');

		drawArray(shapeArray);
	</script>
</body>
</html>